#pragma noce

#include <iostream>

namespace MutexModule
{
    class Mutex
    {
    public:
        Mutex()
        {
            pthread_mutex_init(&_mutex, nullptr);
        }

        void Lock()
        {
            int n = pthread_mutex_lock(&_mutex);
            if(n != 0)
            {
                std::cerr << "Error: pthread_mutex_lock failed with error code " << n << std::endl;
            }
        }

        void UnLock()
        {
            int n = pthread_mutex_unlock(&_mutex);
            if(n != 0)
            {
                std::cerr << "Error: pthread_mutex_unlock failed with error code " << n << std::endl;       
            }
        }

        ~Mutex()
        {
            pthread_mutex_destroy(&_mutex);
        }
    private:
        pthread_mutex_t _mutex;
    };
}